// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import iviewArea from 'iview-area'
import App from './App'
import router from './router'
import myFilters from './myFilters'
import iView from 'iview'
import './theme/index.less'
import 'babel-polyfill';

Vue.directive('title', {
  componentUpdated: function (el, binding) {
    document.title = el.dataset.title
  }
})

Vue.config.productionTip = false

for (let key in myFilters){  //一定要放在 new Vue之前 注册全局过滤器
  Vue.filter(key, myFilters[key])
}

router.beforeEach((to, from, next) => {
  /* 路由发生变化修改页面title */
  if (to.meta.title) {
    document.title = to.meta.title
  }
  next()
})
Vue.use(iviewArea);
Vue.use(iView);
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
